using System;
using System.Collections.Generic;
using System.Text;
using Barrage.Global;

namespace Barrage.Shaders
{
    /// <summary>
    /// Singleton instance of D3DShader that loads the "instancing.fx" shader
    /// </summary>
    public class InstancingShader : D3DShader
    {
        static InstancingShader instance = null;

        /// <summary>
        /// Gets the Geometry instancing shader, creating it if necessary
        /// </summary>
        public static InstancingShader Instance { get { if (instance == null) instance = new InstancingShader(); return instance; } }

        InstancingShader()
            : base("instancing.fx")
        {
            Engine.RegisterDisposeHandler(new EngineDisposeHandler(Dispose));
        }

        /// <summary>
        /// \internal Clear resources
        /// </summary>
        public override void Dispose()
        {
            if (instance==this)
                instance = null;
            base.Dispose();
        }
    }
}
